package com.huitone.smspfm.interfacz.tasks;

import com.huitone.smspfm.interfacz.core.AppStaticConfigs;

/**   
* @Title CleanExpireRptRespSerialNoTask.java 
* @Package com.huitone.smspfm.interfacz.tasks 
* @Description TODO(用一句话描述该文件做什么) 
* @author ybliang   
* @date 2017年8月29日 下午7:00:48 
* @version V1.0   
*/
public class CleanExpireRptRespSerialNoTask extends Thread {
	
	private long expireInteval = 1800000; // 毫秒
	
	private long excuteInteval = 1800000; // 毫秒
	
	private boolean keepGoing = true;

	@Override
	public void run() {
		
		while (!this.isInterrupted() && isKeepGoing()) {
			
			long expireTime = System.currentTimeMillis() - expireInteval;
			
			AppStaticConfigs.zsetOpts.removeByScore(AppStaticConfigs.iSMRptRespSerialNoZSet, 0, expireTime);
			
			try {
				Thread.sleep(excuteInteval);
			} catch (InterruptedException e) {}
		}
	}

	public boolean isKeepGoing() {
		return keepGoing;
	}

	public void setKeepGoing(boolean keepGoing) {
		this.keepGoing = keepGoing;
	}

	@Override
	public void destroy() {
		this.setKeepGoing(false);
		this.interrupt();
	}

}
